<?php
class Core_Frontend_Plugin_Route_Rewrite extends Dcmp_Plugin_Base{
	
	public function execute(){
		$rewriteUrl = $_SERVER['REQUEST_URI'];
		if(Kd_Util_String::endsWith($rewriteUrl, '.html')){
			$url = Kd_Util_String::subString($rewriteUrl, '.');
			$sef = App::getModel('website/collection_sef')
					->filterByRewriteUrl($url)
					->limit(1)
					->load()
					->getFirstItem();
			if($sef->getId()){
				$_SERVER['REQUEST_URI'] = $sef->getSourceUrl();
				$_SERVER['REWRITE_URI'] = $rewriteUrl;
			}
		}
	}
}